package Dao;

import Model.Student;
import UserView.UserUi;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class DaoStuHandle {
    public void showStuDAO(Student[] stus, int len) {
        for (int i = 0; i < len; i++) {
            System.out.println("学生" + (i + 1) + "信息：" + stus[i]);
        }
    }


    public void addStuDAO(Student[] stus, Student stu) {
        stus[UserUi.num++] = stu;
    }

    public void delStuDAO(Student[] stus, Integer len, Integer a) {
        for (int i = 0; i < len - 1; i++) {
            stus[i] = stus[i + 1];

        }
    }
    public void updateStuDAO(Student[] stus, Integer len, Integer a){
        Student student = new Student();
        Scanner scanner = new Scanner(System.in);
        System.out.println("你要修改初始姓名是："+stus[a].getName());
        System.out.println("请输入你修改的姓名");
        String name = scanner.next();
        student.setName(name);
        System.out.println("你要修改初始性别是："+stus[a].getSex());
        System.out.println("请输入你修改的性别");
        String sex = scanner.next();
        student.setSex(sex);
        System.out.println("你要修改初始年龄是："+stus[a].getAge());
        System.out.println("请输入你修改的年龄");
        int age = scanner.nextInt();
        student.setAge(age);
        System.out.println("你要修改初始专业是："+stus[a].getMajor());
        System.out.println("请输入你修改的专业");
        String major = scanner.next();
        student.setMajor(major);
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yy--ss-dd hh-mm-ss");
        String format = simpleDateFormat.format(date);
        student.setTime(format);
        student.setId(stus[a].getId());
        stus[a]=student;
    }
}